<h1 class="pb-0">Dashboard configuration</h1>

{# TODO: Translations #}

<div class="d-inline-block mb-5 mt-0">
  {{ saveButton|raw }}
</div>

{# TODO: Dynamic route #}
<form action="/bladeerp/UI/Dashboard/SaveConfig" method="post" id="dashboard-configuration-form">
  <div class="row">
    <div class="col-md-6">
      {% for key, card in availableCards  %}
        <div class="card shadow mb-2">
          <div class="card-header py-3">
            <h6 class="m-0 font-weight-bold text-primary">
              {% if card['params']['title'] is defined %} {{ card['params']['title'] }} {% else %} {{ key }} {% endif %}</h6>
          </div>
          <div class="card-body row" id="card-{{ key }}-{{ loop.index0 }}">
            <div class="col">
              <span>Left?</span> <br>
              {{ forms[loop.index0][0]|raw }}
            </div>
            <div class="col">
              <span>Is active?</span> <br>
              {{ forms[loop.index0][1]|raw }}
            </div>
            <div class="col">
              <span>Order</span> <br>
              {{ forms[loop.index0][2]|raw }}
            </div>
          </div>
        </div>
      {% endfor %}
    </div>
  </div>
</form>

<script>

  function {{ uid }}_save() {
    const form = document.getElementById('dashboard-configuration-form');

    form.submit();
  }

</script>